<?php

/* реализация
 * $form=$this->beginWidget('CActiveForm', array(
      'id'=>'pet-form',
 *    'enableAjaxValidation'=>false));
 * .......
 * $this->endWidget();
 */

function smarty_block_widgetActiveForm($params, $content, &$smarty)
{
    if (!$content)
    {
        $htmlOptions = (isset($params['attr'])) ? $params['attr'] : array();
        $htmlOptions = array_merge($htmlOptions, array('enctype' => 'multipart/form-data'));
        $widgetActiveForm = Yii::app()->controller->beginWidget('CActiveForm', array(
            'id' => $params['id'],
            'enableAjaxValidation' => $params['enableAjaxValidation'],
            'htmlOptions' => $htmlOptions )
        );
        $smarty->assign('_widgetActiveForm', $widgetActiveForm);
        $smarty->assign('_modelForWidgetActiveForm', $params['model']);
    }
    else
    {
        echo $content;
        Yii::app()->controller->endWidget();
        $smarty->clearAssign('_widgetActiveForm');
        $smarty->clearAssign('_modelForWidgetActiveForm');
    }
}